const mysql = require('mysql2');
const config = require('../app/config');
const connection = mysql.createPool({
    host: config.MYSQL_HOST,
    user: config.MYSQL_USER,
    password: config.MYSQL_PASSWORD,
    database: config.MYSQL_DATABASE,
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0
});
  connection.getConnection(function(err, connection) {
    if (err) {
      console.log(err);   //not connected
      return;
    }
    console.log('connected as id ' + connection.threadId);  //logs the connection id
  });
  module.exports = connection.promise();